package com.anguin.mylibrary.util;

import java.io.Serializable;
import java.sql.Timestamp;

public class JsonResult<E> implements Serializable
{
    public static final int SUCCESS = 200;
    public static final int ERROR = 500;
    public static final int NOT_FOUND = 404;
    public static final int UNAUTHORIZED = 401;
    private Integer code;
    private E data;

    private String message;

    private final long currentTime = System.currentTimeMillis();
    public JsonResult(){}

    public JsonResult(Integer status)
    {
        this.code = status;
    }

    public JsonResult(Throwable e)
    {
        this.message = e.getMessage();
    }

    public JsonResult(Integer status, E data)
    {
        this.code = status;
        this.data = data;
    }
    public JsonResult(Integer status , E data , Throwable  e)
    {
        this.code = status;
        this.data = data;
        this.message = e.getMessage();
    }

    public Integer getCode()
    {
        return code;
    }

    public void setCode(Integer code)
    {
        this.code = code;
    }

    public E getData()
    {
        return data;
    }

    public void setData(E data)
    {
        this.data = data;
    }

    public String getMessage()
    {
        return message;
    }

    public void setMessage(String message)
    {
        this.message = message;
    }

    public long getCurrentTime()
    {
        return currentTime;
    }
}
